from rest_framework.authentication import BaseAuthentication, TokenAuthentication

from authDemo import models


class MyAuthentication(BaseAuthentication):
    def authenticate(self, request):
        token = request.query_params.get('token')
        user_obj = models.UserInfo.objects.filter(token=token)
        if user_obj:
            return (user_obj, token)
        return (None, None)
